<?php
namespace app\http\middleware;
use think\Controller;
use auth\Action;
use base\BaseMethod;
use app\admin\model\SystemParamValue;

/**
* token验证中间件
* Class AuthTokenMiddleware
* @package app\http\middleware
*/
class WebBaseConfig extends Controller
{
	//自执行中间件方法
   	public function handle($request, \Closure $next){
   	    //如果未初始化
        if( !file_exists( base_path().'/views/system/baseInstall/insall.lock' ) ){
            if($request->controller() != "Soft.install"){
                return $this->fetch('system/baseInstall/index');
            }
        }else{
            $model = SystemParamValue::where('param_scope','系统基础配置');
            $result = $model->field('param_code as code,param_value as value')->select();
            foreach ($result as $key => $item) {
                \Env::set($item['code'], json_decode($item['value'],true));
            }
        }
        return $next($request);
    }
	
}